
#ifndef HARDWARE_PROFILE_CUSTOM_H
#define HARDWARE_PROFILE_CUSTOM_H

    /*******************************************************************/
    /******** USB stack hardware selection options *********************/
    /*******************************************************************/
    //This section is the set of definitions required by the MCHPFSUSB
    //  framework.  These definitions tell the firmware what mode it is
    //  running in, and where it can find the results to some information
    //  that the stack needs.
    //These definitions are required by every application developed with
    //  this revision of the MCHPFSUSB framework.  Please review each
    //  option carefully and determine which options are desired/required
    //  for your application.

    //The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO
    //and USE_USB_BUS_SENSE_IO features.  Uncomment the below line(s) if
    //it is desireable to use one or both of the features.
    //#define USE_SELF_POWER_SENSE_IO
    #define tris_self_power     TRISAbits.TRISA2    // Input
    #if defined(USE_SELF_POWER_SENSE_IO)
    #define self_power          PORTAbits.RA2
    #else
    #define self_power          1
    #endif

    #define USE_USB_BUS_SENSE_IO
    #define tris_usb_bus_sense  TRISCbits.TRISC2    // Input
    #if defined(USE_USB_BUS_SENSE_IO)
    #define USB_BUS_SENSE       PORTCbits.RC2
    #else
    #define USB_BUS_SENSE       1
    #endif

    //Uncomment the following line to make the output HEX of this  
    //  project work with the MCHPUSB Bootloader    
    //#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
	
    //Uncomment the following line to make the output HEX of this 
    //  project work with the HID Bootloader
    #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER		

    /*******************************************************************/
    /******** MDD File System selection options ************************/
    /*******************************************************************/
    #define USE_PIC18

    #define ERASE_BLOCK_SIZE        64
    #define WRITE_BLOCK_SIZE        32

    /*******************************************************************/
    /*******************************************************************/
    /*******************************************************************/
    /******** Application specific definitions *************************/
    /*******************************************************************/
    /*******************************************************************/
    /*******************************************************************/

    /** Board definition ***********************************************/
    //These defintions will tell the main() function which board is
    //  currently selected.  This will allow the application to add
    //  the correct configuration bits as wells use the correct
    //  initialization functions for the board.  These defitions are only
    //  required in the stack provided demos.  They are not required in
    //  final application design.

    //#define DEMO_BOARD PICDEM_FS_USB
    //#define PICDEM_FS_USB
    #define CLOCK_FREQ 48000000

    /** FPGA ************************************************************/
	#define fpga_reset				LATAbits.LATA5
	#define fpga_clksel				LATBbits.LATB5
	#define fpga_manclk				LATCbits.LATC0
	#define fpga_writeclk			LATCbits.LATC1
	#define fpga_data				LATD
	#define mSetFpgaAddr(a)			LATA &= ((a << 1) | 0xE1); LATA |= ((a << 1) & 0x1E);

	#define mInitFpga()				LATD = 0x00; TRISD = 0x00; LATB &= 0xDF; TRISB &= 0xDF; LATC &= 0xFC; TRISC &= 0xFC; LATA &= 0xC1; TRISA &= 0xC1;

    /** D/A ************************************************************/
	
	#define mInitDA()				LATB &= 0xE3; TRISB &= 0xE3;	// DA Select
	#define mSelectDA(a)			LATB &= ((0x01 << (a + 1)) | 0xE3); LATB |= ((0x01 << (a + 1)) & 0x1C);

    /** LED ************************************************************/
    #define mInitAllLEDs()      LATC &= 0x3F; TRISC &= 0x3F;//LATB &= 0x3F; TRISB &= 0x3F;//LATD &= 0xF0; TRISD &= 0xF0;

    #define mLED_1              LATCbits.LATC6
    #define mLED_2              LATCbits.LATC7
    #define mLED_3              LATCbits.LATC6
    #define mLED_4              LATCbits.LATC7
    
    #define mGetLED_1()         mLED_1
    #define mGetLED_2()         mLED_2
    #define mGetLED_3()         mLED_3
    #define mGetLED_4()         mLED_4

    #define mLED_1_On()         mLED_1 = 1;
    #define mLED_2_On()         mLED_2 = 1;
    #define mLED_3_On()         mLED_3 = 1;
    #define mLED_4_On()         mLED_4 = 1;
    
    #define mLED_1_Off()        mLED_1 = 0;
    #define mLED_2_Off()        mLED_2 = 0;
    #define mLED_3_Off()        mLED_3 = 0;
    #define mLED_4_Off()        mLED_4 = 0;
    
    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
    
    
    /** TRIS ***********************************************************/
    #define INPUT_PIN           1
    #define OUTPUT_PIN          0

#endif  //HARDWARE_PROFILE_CUSTOM_H
